package com.wbc.smartHome.dao;

import com.wbc.smartHome.model.LiveTV;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Date;
import java.util.List;

public interface LiveTVDao {

    @Select(" select lt.id,lt.name,lt.img,lt.url,a.account as adminName,lt.start_time,lt.oper_time from live_tv lt inner join admin a on a.id = lt.adminid")
    List<LiveTV> getLiveTVList();

    @Insert("INSERT INTO live_tv(name,img,url,adminid,start_time,oper_time)values(#{name},#{img},#{url},#{adminId},#{startTime},now())")
    void setLiveTVList(String name, String img, String url, Date startTime, int adminId);

    @Update("update live_tv set name =#{name},img = #{img},url = #{url},adminid = #{adminId},oper_time = now() where id = #{id}")
    void updateLiveTV(Integer id, String name, String img, String url,Date startTime,int adminId);

    @Delete("delete from live_tv where id = #{id}")
    void delete(int id);

    @Select("select id,name,img,url,start_time,oper_time from live_tv where id =#{id}")
    LiveTV getLiveTVById(int id);

}
